﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using GeneralClasses;

namespace Interface
{
    public partial class frmPreferences : Form
    {
        Person employee;
        Form opener;
        List<Shift> shifts;

        public frmPreferences(Form Opener, Person Employee)
        {
            employee = Employee;
            opener = Opener;
            InitializeComponent();
        }

        void refresh()
        {
            dgvShifts.Rows.Clear();
            shifts = Schedule.getWeeklyTemplateSchedule().ShiftMasterList;
            foreach (Shift current in shifts)
            {
                string skills = "";
                foreach (Skill skill in current.Skills)
                {
                    skills += skill.Name = " ";
                }

                string startTime = current.EndTime.DayOfWeek.ToString() + " " +
                    current.EndTime.TimeOfDay.ToString();
                string endTime = current.EndTime.DayOfWeek.ToString() + " " +
                    current.EndTime.TimeOfDay.ToString();

               /* if (current.Departments.Count > 0)
                {
                    //load user's preferences on shift
                    dgvShifts.Rows.Add(true, current.getAssignedPersons()[0].FullName,
                        current.Name, startTime, endTime,
                        1, current.Departments[0].Name, skills);
                }
                else
                {
                    //load user's preferences on shift
                    dgvShifts.Rows.Add(true, current.getAssignedPersons()[0].FullName,
                        current.Name, startTime, endTime,
                        1, "", skills);
                }*/
            }
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            bool success = true;

            if (true /*preferences.save()*/)
            {
                MessageBox.Show("Unable to save preferences to database!");
            }
            else
            {
                this.Close();
            }
        }

        private void frmPreferences_Shown(object sender, EventArgs e)
        {
            refresh();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void frmPreferences_FormClosing(object sender, FormClosingEventArgs e)
        {
            opener.Show();
        }
    }
}
